import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q=in.nextInt();
        int cnt=0;
        while(cnt<q){
            int a=in.nextInt();
            int b=in.nextInt();
            int c=in.nextInt();
            int score=0;
            int min=findMin(a,b,c);
            if(b>min){
                score=b-min-1+2*min;
            }else{
                score=2*min;
            }
            System.out.println(score);
            cnt++;
        }
    }
    public static int findMin(int a,int b,int c){
        int min=a;
        if(min>b) min=b;
        if(min>c) min=c;
        return min;
    }
}